package cn.qf;

import cn.qf.v1.Car;
import cn.qf.v1.Truck;
import cn.qf.v2.Vehicle;

import java.util.Scanner;

public class VehicleApp {

    private static final Scanner scanner = new Scanner(System.in);

    private static final String[] brands = {"红旗", "长城"};

    private static final String[] loads = {"5T", "10T", "15T"};

    public static void main(String[] args) {
        System.out.println("请选择所租车辆的类型：（1 - 轿车；2 - 卡车）");
        byte type = scanner.nextByte();

        int num = 0;
        String name = "";

        Vehicle vehicle = null;
        switch (type) {
            case 1:
                System.out.println("请选择品牌：（1 - 红旗；2 - 长城）");
                num = scanner.nextInt();

                String brand = null;
                if(num <= 0 || num > brands.length){
                    System.out.println("所选车辆品牌尚不能提供！");
                    System.exit(0);
                }else{
                    brand = brands[num-1];
                }

                System.out.println("请给所租车辆起名：");
                name = scanner.next();

                Car car = new Car(name, brand);
                car.show();
                break;
            case 2:
                System.out.println("请选择吨位：（1 - 5T；2 - 10T；3 - 15T）");
                num = scanner.nextInt();

                String load = null;
                if(num <= 0 || num > brands.length){
                    System.out.println("所选车辆吨位尚不能提供！");
                    System.exit(0);
                }else{
                    load = loads[num-1];
                }

                System.out.println("请给所租车辆起名：");
                name = scanner.next();

                Truck truck = new Truck(name, load);
                truck.show();
                break;
            default:
                System.out.println("所租车辆尚无法提供。");
                System.exit(0);
        }

    }
}
